forked from dudykr/stc
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[pull] main from dudykr:main #12
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
**Description:** implement `keyof this` ```ts // @strict: true // @declaration: true type OldDiff<T extends keyof any, U extends keyof any> = ( & { [P in T]: P; } & { [P in U]: never; } & { [x: string]: never; } )[T]; interface A { a: 'a'; } interface B1 extends A { b: 'b'; c: OldDiff<keyof this, keyof A>; } type c1 = B1['c']; // 'c' | 'b' ```
**Description:** ```ts // @strictNullChecks: true // @declaration: true enum E { A, B, C }; type K15 = keyof E; // "toString" | "toFixed" | "toExponential" | ... ```
Thank you for the PR! Files to checkThese are files which is affected by the current PR, but not reflected. If there's no file below this message, please ignore this message. You can run
|
**Description:** ```ts // @strictNullChecks: true // @declaration: true class A<T> { props: T & { foo: string }; } class B extends A<{ x: number}> { f(p: this["props"]) { p.x; } } ```
**Description:** ```ts function f90<T extends S2, K extends keyof S2>(x1: S2[keyof S2], x2: T[keyof S2], x3: S2[K]) { x1 = x2; x1 = x3; x2 = x1; x2 = x3; x3 = x1; x3 = x2; x1.length; x2.length; x3.length; } ```
**Description:** When comparing TSC to error, we took the error results from ACTUAL. In actual, the rules for each file were not applied properly, As a result, tests like strictNullCheck didn't work correctly. To fix this, we unified the env import code within the tests.
…1072) **Description:** ```ts function l<T extends {}, P extends keyof T>(s: string, tp: T[P]): void { tp = s; } ```
**Description:** ```rs if r.is_num() { match src.parse() { Ok(v) => { return Type::Lit(LitType { span, lit: RTsLit::Number(RNumber { span, value: v, raw: None }), metadata: Default::default(), tracker: Default::default(), }) } Err(..) => { return Type::Keyword(KeywordType { span, kind: TsKeywordTypeKind::TsNumberKeyword, metadata: Default::default(), tracker: Default::default(), }) } } } ```
**Description:** ```ts type A = 1 | 2; function f<T extends A>(a: T): A & T { return a; } // Shouldn't error ```
…ndefined` (#1073) **Description:** ```ts function f10<T>(x: T, y: Partial<T>, k: keyof T) { x[k] = y[k]; // Error y[k] = x[k]; } ```
#1067) **Description:** ```ts function l<T extends {}, P extends keyof T>(s: string, tp: T[P]): void { tp = s; } function m<T extends { a: number }, P extends keyof T>(s: string, tp: T[P]): void { tp = s; } function f<T extends object, P extends keyof T>(s: string, tp: T[P]): void { tp = s; } ```
**Related issue:** - Part of #705
**Description:** ```ts type TBigInt2 = "0x10" extends `${infer N extends bigint}` ? N : never; // bigint (not round-trippable) type TBigInt3 = "0o10" extends `${infer N extends bigint}` ? N : never; // bigint (not round-trippable) type TBigInt4 = "0b10" extends `${infer N extends bigint}` ? N : never; // bigint (not round-trippable) ```
**Description:** ```ts declare global { interface ImportMeta {foo?: () => void} }; if (import.meta.foo) { import.meta.foo(); } ```
**Description:** ```rs let main_src = Arc::new(fs::read_to_string(file_name).unwrap()); // Postpone multi-file tests. if main_src.contains("<reference path") { panic!("`<reference path` is not supported yet"); } ``` remove it for next ```tsx /// <reference lib="dom" /> ``` **Deep Dive** this code wrote #487 I'm guessing it was used as a pass-through because it was a test case that was too much for the code to handle at the time. And I don't think it matters if you delete that code now.
**Description:** This PR implements checker behaviors for `wasm` binding. By supporting wasm, implementing playground will become very easy. I also implemented PoC of playground and it works well. I'll contribute on that when this PR is ready and merged. Due to the constraints of wasm, there is a few APIs that should not be used. Below is the list. - `std::time::Instant` - `mimalloc_rust` from `swc_node_base` - All file-system related APIs. We dropped some code to avoid use of the APIs, and this PR contains those changes. I marked this PR as draft; we have to manage them somehow before merge it. **Related issue:** - #300 - #1021
**Description:** ```ts declare module "foo2" { namespace Bar { interface I { a: string; b: number; } } namespace Baz { interface J { a: number; b: string; } } class Bar { item: Bar.I; constructor(input: Baz.J); } } let y: import("foo2").Bar.I = { a: "", b: 0 }; ```
#1103) **Description:** ```ts interface I31<T> extends T { x: string } ``` I have a concern. The following functions cause duplicate error handling due to duplicate function calls. ```rs #[validator] impl Analyzer<'_, '_> { fn validate(&mut self, d: &RTsInterfaceDecl) -> VResult<Type> { let ty = self.with_child(ScopeKind::Flow, Default::default(), |child: &mut Analyzer| -> VResult<_> { match &*d.id.sym { "any" | "void" | "never" | "unknown" | "string" | "number" | "bigint" | "boolean" | "null" | "undefined" | "symbol" => { child.storage.report(ErrorKind::InvalidInterfaceName { span: d.id.span }.into()); } _ => {} } let mut ty = Interface { span: d.span, name: d.id.clone().into(), type_params: try_opt!(d.type_params.validate_with(&mut *child).map(|v| v.map(Box::new))), extends: d.extends.validate_with(child)?.freezed(), body: d.body.validate_with(child)?, metadata: Default::default(), tracker: Default::default(), }; child.prevent_expansion(&mut ty.body); ty.body.freeze(); child.resolve_parent_interfaces(&d.extends, true); child.report_error_for_conflicting_parents(d.id.span, &ty.extends); child.report_error_for_wrong_interface_inheritance(d.id.span, &ty.body, &ty.extends); let ty = Type::Interface(ty).freezed(); Ok(ty) })?; // TODO(kdy1): Recover self.register_type(d.id.clone().into(), ty.clone()); Ok(ty) } } ``` `child.resolve_parent_interfaces` and `child.report_error_for_wrong_interface_inheritance` call `report_error_for_unresolved_type` this fn cause `ErrorKind::TypeNotFound` This PR only clogs the hole. If there seems to be a need for fundamental improvement, please open up the issue
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by pull[bot]
Can you help keep this open source service alive? 💖 Please sponsor : )